﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Web.Mvc;
using Tsingda.CacheModule;

namespace TestWeb.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!\r\n" + DateTime.Now.Ticks.ToString();

            //FileStream fs = new FileStream(Server.MapPath("/index.html"), FileMode.Open);
            //byte[] bytes = new byte[fs.Length];
            //fs.Read(bytes, 0, (int)fs.Length);
            //fs.Close();
            //string s = System.Text.Encoding.GetEncoding("utf-8").GetString(bytes);
            //int maxNum = 100000;
            //for (int k = 0; k < maxNum; k++)
            //{
            //    CacheManage.Add(k.ToString(), s);
            //}

            return View();
        }

        public ActionResult About()
        {
            //Response.Write("counts:" + System.Web.HttpContext.Current.Cache.Count + "<br>");
            //IDictionaryEnumerator enumerator = System.Web.HttpContext.Current.Cache.GetEnumerator();
            //while (enumerator.MoveNext())
            //{
            //    Response.Write(enumerator.Key + "<br>");
            //}


            //object o = Tsingda.CSCache.Get("aas");
            //Response.Write(o == null?"e":"f");
            //Response.Write("<br>" + Tsingda.CSCache.Get("aas").ToString() + "aa");
            return View();
        }

        public ActionResult RedirectUrl(string url)
        {
            RedirectResult result = new RedirectResult(url);

            return Content(HttpContext.Request.Url.AbsoluteUri.Replace("http://www.eee114.com/", "http://old.eee114.com/"));
            //return result;
        }
    }
}
